<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.system.*" %>
<%

	HashList code009	= CommonUtil.getCodeList("009");	//권한
	HashList codeUseYn	= CommonUtil.getCodeList("use_yn");	//사용여부


	String s_auth_code		= StringUtil.nvl(request.getParameter("s_auth_code"));
	String s_user_name		= StringUtil.toHan(request.getParameter("s_user_name"));


	HashMap infos = new HashMap();
	infos.put("auth_code",	s_auth_code);
	infos.put("user_name",	s_user_name);

	AdminDAO dao 	= new AdminDAO();
	HashList list 	= dao.selectUserList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#s_name').focus().select();
		$('#list').find('tr').hover(
				function () { $(this).addClass("hover"); }
			  , function () { $(this).removeClass("hover"); }
			)
			.click(function(){
				//$('#hotel_id').val($(this).attr('hotel_id'));
				//$('#searchForm').attr('action', './hotelDetail.jsp');
				//$('#searchForm').submit();
			});
		$('#list').find('input, select').change(function() {
			$(this).closest('tr').find('input[name="list.job_type"]').val('U');
		});
	});


	function fnSave() {
		$("#saveForm").attr('action', './userSave.do');
		$("#saveForm").submit();
	}

	function fnAddRow() {

		var txt = '<tr><td align="center"><input type="hidden" name="list.job_type" value="C"  /><input type="checkbox" name="chk" /></td>'
				+ '<td><input type="text" name="list.user_id" value="" class="wmax"/></td>'
				+ '<td><input type="text" name="list.user_pw" value="" class="wmax"/></td>'
				+ '<td><input type="text" name="list.user_name" value="" class="wmax"/></td>'
				+ '<td><select name="list.auth_code" class="wmax"><%= StringUtil.makeOption(code009, "") %></select></td>'
				+ '<td><input type="text" name="list.user_info" value="" class="wmax"/></td>'
				+ '<td><select name="list.use_yn" class="wmax"><option value="Y">사용</option><option value="N">미사용</option></select></td>'
				+ '<td></td></tr>';

		$("#list").append(txt);
	}

	function fnDeleteRow() {
		var chks = $('input:checkbox[name="chk"]:checked');
		for (var i = 0; i < chks.length; i++) {
			$(chks[i]).closest('tr').find('input[name="list.job_type"]').val('D');
			$(chks[i]).closest('tr').hide();
		}
	}
	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/admin/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/admin/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1>사용자관리</h1>
				<p>관리자 > 시스템관리 > <b>사용자관리</b></p>
			</div>
			<div class="clear line_01"></div>

			<form id="searchForm" method="post" action="./userList.jsp">
			<table cellpadding="0" cellspacing="0" class="table_01 mt15">
			<colgroup>
				<col width="100px" />
				<col width="160px" />
				<col width="100px" />
				<col  />
			</colgroup>
			<tr>
				<th><p>권한</p></th>
				<td>
					<select name="s_author_code" class="w120">
						<option value="">전체</option>
						<%= StringUtil.makeOption(code009, s_auth_code) %>
					</select>
				</td>
				<th><p>성명</p></th>
				<td class="brx">
					<input type="text" name="s_user_name" id="s_user_name" value="<%= s_user_name %>" class="w120"/>
				</td>
			</tr>
			</table>

			<div class="mt10 mb10 r">
				<input type="image" class="button" src="../images/btn_search.gif">
			</div>

			</form>




			<div class="search_result">검색결과 : <%= list.size() %>건</div>

			<form id="saveForm" method="post" action="./userSave.do">
		    <table cellpadding="0" cellspacing="0" class="table_03">
				<colgroup>
					<col width="40px"/>
					<col width="120px"/>
					<col width="120px"/>
					<col width="120px"/>
					<col width="120px"/>
					<col width="400px"/>
					<col width="80px"/>
				</colgroup>
				<thead>
					<tr>
						<th><p><input type="checkbox" name="chkAll" id="chkAll"/></p></th>
						<th><p>아이디</p></th>
						<th><p>성명</p></th>
						<th><p>부서</p></th>
						<th><p>권한</p></th>
						<th><p>설명</p></th>
						<th><p>사용여부</p></th>
					</tr>
				</thead>
				<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
					<tr>
						<td>
							<input type="hidden" name="list.job_type" value="X" class="w20" />
							<input type="hidden" name="list.user_id" value="<%= list.get("user_id", i) %>"  />
							<input type="checkbox" name="chk" value=""/>
						</td>
						<td><%= list.get("user_id", i) %></td>
						<td><%= list.get("user_name", i) %></td>
						<td><%= list.get("dept_name", i) %></td>
						<td>
							<select name="list.auth_code" class="wmax">
							<%= StringUtil.makeOption(code009, list.get("auth_code", i)) %>
							</select>
						</td>
						<td class="l"><%= list.get("user_info", i) %></td>
						<td>
							<select name="list.use_yn" class="wmax">
							<%= StringUtil.makeOption(codeUseYn, list.get("use_yn", i)) %>
							</select>
						</td>
					</tr>
			<%	} %>
				</tbody>
			</table>

			<div class="mt20 mb10 c">
				<img src="../images/btn_addrow.gif" style="cursor:hand" onclick="fnAddRow()"/>
				<img src="../images/btn_delrow.gif" style="cursor:hand" onclick="fnDeleteRow()"/>
				<input type="image" class="button" src="../images/btn_save.gif" />
			</div>
			</form>
		</div>
	</div>
</div>
</body>
</html>
